import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'



// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    host: '0.0.0.0', // ip
    port: 8080,
    hmr: true, // 热启动
    open: true, // 自动打开浏览器
    // 反向代理
    proxy: {
      '/api/auth/': {
        target: 'http://43.139.99.222:3001', //实际请求地址
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, ''),
      },
    },
  },
  // base: "./",
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },

  css: {
    preprocessorOptions: {
      // 全局样式引入
      scss: {
        additionalData: '@import "@/main.scss";',
        // javascriptEnabled: true
      },
    },
  },
});
